
import 'package:flutter/material.dart';
import 'package:flutter_hotwork/Myapplication.dart';
import 'package:flutter_hotwork/bean/hotuserinfobean.dart';
import 'package:flutter_hotwork/homepage/BaseTitleBar.dart';
import 'package:flutter_hotwork/homepage/BaseViewBar.dart';
import 'package:flutter_hotwork/zhifa/QuestionEdit.dart';
import 'package:flutter_hotwork/zhifa/QuestionListBean.dart';
import 'package:fluttertoast/fluttertoast.dart';

import '../HomePage.dart';
import 'ChangeAct.dart';

class ReYongHuShuJuScreen extends StatefulWidget {
  @override
  ReYongHuShuJuState createState() => new ReYongHuShuJuState();

}
class ReYongHuShuJuState extends State<ReYongHuShuJuScreen> {
  @override
  Widget build(BuildContext context) {
    ScrollController controller = ScrollController();
    double rpx = MediaQuery.of(context).size.width / 750;
    return Scaffold(
      appBar: new BaseViewBar(
          childView: new BaseTitleBar(
            "热用户数据",
            leftIcon: 'images/fanhui.png',
            rightIcon:  '',
            rightClick: () {
              print("点击了右边干嘛啊。。。哦");

            },
            leftClick: () {
              print("点击了左边干嘛啊。。。哦");
              Navigator.of(context).pop();
            },
          ),
          preferredSize: Size.fromHeight(50.0)),


      body:
      Card(
        child:
        Column(
          children: [
            Expanded(
              child:
              genContentList(
                  MyApplication.hotuserbean.lineHotUserInfoTotalVos,context, controller
              ),
            ),
          ],
        ),
      ),
    );
  }
}



genContentList(List<LineHotUserInfoTotalVos> data, BuildContext context, controller){
  double rpx = MediaQuery.of(context).size.width / 750;

  List<FocusHotUserVos> focusHotUserVos = new List();
  return ListView.builder(
      shrinkWrap: true,
      controller: controller,
      itemCount: data.length,
      itemBuilder:(BuildContext context, int index){
        return
          ExpansionTile(
            title: Text(data[index].lineName,style: TextStyle(fontSize: 12),),
            children:  data[index].focusHotUserVos.map((posi) =>
                Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.all(Radius.circular(5)),
                    boxShadow: <BoxShadow>[//设置阴影
                      new BoxShadow(
                        color: Colors.grey,//阴影颜色
                        blurRadius:5.0,//阴影大小
                      ),
                    ],
                  ),

                  margin: EdgeInsets.only(left: 10,top: 10,right: 10,bottom:10),
                  height: 410 * rpx,
                  child: Column(
                    children: <Widget>[
                      Container(
                        height: 10,
                      ),
                      Container(
                        padding: EdgeInsets.only(left: 10,top: 0,right: 10,bottom:0),
                        child: Row(
                          crossAxisAlignment:CrossAxisAlignment.center,
                          children: [
                            Container(
                              width: 2,
                              height: 15,
                              color: Colors.blue,
                            ),
                            Container(
                              width: 10,
                            ),
                            Text(posi.fullName,style: new TextStyle(color: Color(0xFF333333),
                              fontSize: 12.0,
                            ),),
                            Flexible(fit: FlexFit.tight, child: SizedBox()),
                            Text(posi.newest.toString(),style: new TextStyle(color: Color(0xFF333333),
                              fontSize: 12.0,
                            ),),

                          ],
                        ),
                      ),
                      Container(
                        height: 1,
                        margin: EdgeInsets.only(left: 10,top: 5,right: 10,bottom: 0),
                        color: Colors.grey[300],
                      ),
                      Container(
                        padding: EdgeInsets.only(left: 10,top: 0,right: 10,bottom:0),
                        margin: EdgeInsets.only(left: 0,top: 5,right: 0,bottom: 0),
                        child: Row(
                          children: [
                            // Image(height:20,width: 20,image: AssetImage('images/mingcheng.png')),
                            Container(
                              width: 10,
                            ),

                            Container(
                              width: 120,
                              child:
                              Text("用户编号:"+posi.userNumber,style: new TextStyle(color: Color(0xFF333333),
                                fontSize: 12.0,
                              ),),
                            ),
                            Container(
                              width: 50,
                            ),
                            // Image(height:20,width: 20,image: AssetImage('images/weizhi.png')),
                            Container(
                              width: 10,
                            ),
                            Text("工作温度:"+posi.jobTemperature.toString(),style: new TextStyle(color: Color(0xFF333333),
                              fontSize: 12.0,
                            ),),
                          ],
                        ),
                      ),

                      Container(
                        padding: EdgeInsets.only(left: 10,top: 0,right: 10,bottom:0),
                        margin: EdgeInsets.only(left: 0,top: 5,right: 0,bottom: 0),
                        child: Row(
                          children: [
                            // Image(height:20,width: 20,image: AssetImage('images/mingcheng.png')),
                            Container(
                              width: 10,
                            ),
                            Container(
                              width: 120,
                              child:
                              Text("阀后温度:"+posi.afterValveTemperature.toString(),style: new TextStyle(color: Color(0xFF333333),
                                fontSize: 12.0,
                              ),),
                            ),
                            Container(
                              width: 50,
                            ),
                            // Image(height:20,width: 20,image: AssetImage('images/weizhi.png')),
                            Container(
                              width: 10,
                            ),
                            Text("工作压力:"+posi.jobStress.toString(),style: new TextStyle(color: Color(0xFF333333),
                              fontSize: 12.0,
                            ),),
                          ],
                        ),
                      ),
                      Container(
                        padding: EdgeInsets.only(left: 10,top: 0,right: 10,bottom:0),
                        margin: EdgeInsets.only(left: 0,top: 5,right: 0,bottom: 0),
                        child: Row(
                          children: [
                            // Image(height:20,width: 20,image: AssetImage('images/mingcheng.png')),
                            Container(
                              width: 10,
                            ),
                            Container(
                              width: 120,
                              child:
                              Text("瞬时流量:"+posi.instantFlow.toString(),style: new TextStyle(color: Color(0xFF333333),
                                fontSize: 12.0,
                              ),),
                            ),
                            Container(
                              width: 50,
                            ),
                            // Image(height:20,width: 20,image: AssetImage('images/weizhi.png')),
                            Container(
                              width: 10,
                            ),
                            Text("累计流量:"+posi.totalFlow.toString(),style: new TextStyle(color: Color(0xFF333333),
                              fontSize: 12.0,
                            ),),
                          ],
                        ),
                      ),
                      Container(
                        padding: EdgeInsets.only(left: 10,top: 0,right: 10,bottom:0),
                        margin: EdgeInsets.only(left: 0,top: 5,right: 0,bottom: 0),
                        child: Row(
                          children: [
                            // Image(height:20,width: 20,image: AssetImage('images/mingcheng.png')),
                            Container(
                              width: 10,
                            ),
                            Container(
                              width: 120,
                              child:
                              Text("剩余汽量:"+posi.surplusFlow.toString(),style: new TextStyle(color: Color(0xFF333333),
                                fontSize: 12.0,
                              ),),
                            ),
                            Container(
                              width: 50,
                            ),
                            // Image(height:20,width: 20,image: AssetImage('images/weizhi.png')),
                            Container(
                              width: 10,
                            ),
                            Text("余额:"+posi.balance.toString(),style: new TextStyle(color: Color(0xFF333333),
                              fontSize: 12.0,
                            ),),
                          ],
                        ),
                      ),
                      Container(
                        height: 1,
                        margin: EdgeInsets.only(left: 10,top: 5,right: 10,bottom: 10),
                        color: Colors.grey[300],
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Container(
                            width: 80,
                            child:
                            Column(
                              mainAxisAlignment: MainAxisAlignment.center,
//                      textDirection: TextDirection.,
                              children: [
                                posi.valveStatus!=3?
                                Image(
                                  height: 15,
                                  width: 15,
                                  image:AssetImage(posi.valveStatus==0?"images/lvse.png":"images/hongse.png"),)
                                    :Container(  height: 15,
                                  width: 15,),
                                Text("电动阀",style: TextStyle(color: const Color(0xFF333333),fontSize: 12),),
                              ],
                            ),
                          ),
                          Container(
                            width: 80,
                            child:
                            Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image(
                                  height: 15,
                                  width: 15,
                                  image:AssetImage(posi.dataStatus==1?"images/lvse.png":"images/hongse.png"),),
                                Text("数据",style: TextStyle(color: const Color(0xFF333333),fontSize: 12),),
                              ],
                            ),
                          ),
                          Container(
                            width: 80,
                            child:
                            Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image(
                                  height: 15,
                                  width: 15,
                                  image:AssetImage(posi.communicationStatus==1?"images/lvse.png":"images/hongse.png"),),
                                Text("通讯",style: TextStyle(color: const Color(0xFF333333),fontSize: 12),),
                              ],
                            ),
                          ),
                          Container(
                            width: 80,
                            child:
                            Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image(
                                  height: 15,
                                  width: 15,
                                  image:AssetImage(posi.alarmStatus==1?"images/lvse.png":"images/hongse.png"),),
                                Text("报警",style: TextStyle(color: const Color(0xFF333333),fontSize: 12),),

                              ],
                            ),
                          ),
                        ],
                      ),


                      // InkWell(
                      //   onTap: (){
                      //     if( MyApplication.loginuserinfo.userInfo.amHotuser==0){
                      //       MyApplication.changedidongfabean = posi;
                      //       Navigator.push(context, MaterialPageRoute(builder: (context) {
                      //         return new changeactivity();
                      //       }));
                      //     }
                      //
                      //   } ,
                      //   child:
                      //   Container(
                      //     margin: EdgeInsets.only(top: 5,bottom: 5),
                      //     padding: EdgeInsets.only(top: 3),
                      //     decoration: BoxDecoration(
                      //       // border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                      //       color: MyApplication.loginuserinfo.userInfo.amHotuser==0?Colors.orange:Colors.grey, // 底色
                      //       borderRadius: BorderRadius.all(Radius.circular(5)),
                      //     ),
                      //     width: 80,
                      //     height: 20,
                      //     child:
                      //     Text("电动阀控制",style: TextStyle(color: Colors.white,fontSize: 10),                textAlign: TextAlign.center,),
                      //
                      //   ),
                      // ),

                    ],
                  ),
                )).toList(),
            // Expanded(
            //   child:
            // Flexible(
            //   child:
            // getItemContentList(data[index].focusHotUserVos,context,controller),
            // )
            // )

          );
      }
  );
}
















void _login() {

}